package com.gviiii.pprf.utils;

import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Objects;

public class PropertiesUtils {

    private static ClassLoader classLoader;

    public static String CLASSPATH_HOME;

    /**
     * 获取classpath
     */
    static {
        classLoader = PropertiesUtils.class.getClassLoader();
        try {
            CLASSPATH_HOME=Paths.get(Objects.requireNonNull(classLoader.getResource("")).toURI()).toString();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }

    public static String getClasspathHome(){
        try {
            return CLASSPATH_HOME=Paths.get(Objects.requireNonNull(classLoader.getResource("")).toURI()).toString();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        return "";
    }
}
